package edu.scau.divineplace.service;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import edu.scau.divineplace.util.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.util.UUID;

/**
 * @Author: x1aolone
 * @Date: 2020/12/11 15:48
 */
@Service
public class ImageService {

    public String get(String fileName){
        byte[] bytes = FileUtils.get(fileName);
        String base64Img = Base64.encode(bytes);
        return base64Img;
    }

    /**
     * 存储图片
     * @param file
     * @return
     * @throws IOException
     */
    public String add(MultipartFile file) throws IOException {
        String fileName = FileUtils.add(file.getBytes());
        return fileName;
    }



}
